﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GameSquares
{

        public partial class FormGameSettings :  Form
    {
       
            public FormGameSettings(Control parent)
        {
            InitializeComponent();
            formParent = parent;
        }

        Control formParent = null;


        private void FormGameSetting_Load(object sender, EventArgs e)
        {


             
            switch (CurrentGraphItem)
            {
                case GraphItem.TypeGraphItem.tEllipse:
                    radioButtonEllipse.Checked = true;
                    break;
                case GraphItem.TypeGraphItem.tRectangle:
                    radioButtonRectangle.Checked = true;
                    break;
                case GraphItem.TypeGraphItem.tRhombus:
                    radioButtonRhombus.Checked = true;
                    break;
            }
        }

        public GraphItem.TypeGraphItem CurrentGraphItem;

        void InitGraphItem(ref GraphItem ball, Control parent)
        {
            ball = new GraphItem(parent);
            GraphItem.CurrentTypeGraphItem = CurrentGraphItem;
            ball.Visible = true;
            ball.Color = Color.Red;
            ball.Active = true;
            ball.CellCoordinate = new Rectangle(-1, -1, parent.Width, parent.Height);
        }


        private void radioButtonsGraphTypeItem_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;
            if (rb.Checked == true)
            {
                if (rb.Equals(radioButtonEllipse) == true)
                {
                    GraphItem.CurrentTypeGraphItem = GraphItem.TypeGraphItem.tEllipse;
                }
                else if (rb.Equals(radioButtonRectangle) == true)
                {
                    GraphItem.CurrentTypeGraphItem = GraphItem.TypeGraphItem.tRectangle;
                }
                else
                {
                    GraphItem.CurrentTypeGraphItem = GraphItem.TypeGraphItem.tRhombus;
                }

                formParent.Invalidate();
            }

        }

        
       //клік ок
        private void buttonOK_Click(object sender, EventArgs e)
        {
            CurrentGraphItem = GraphItem.CurrentTypeGraphItem;
            formParent.Invalidate();
        }

        //Якщо відміна повертаєм
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            GraphItem.CurrentTypeGraphItem = CurrentGraphItem;
            formParent.Invalidate();
        }

        private void FormGameSetting_FormClosed(object sender, FormClosedEventArgs e)
        {
            // Якщо вікно закрите то відміна
            buttonCancel_Click(null, null);
        }

       
    }
}
